<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>webdoc</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            webdoc
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-dva.html">30.cms-10-dva</a></li><li><a href="../html/30.cms-11-front.html">30.cms-11-front</a></li><li><a href="../html/31.cms-12-api.html">31.cms-12-api</a></li><li><a href="../html/31.cms-13-front.html">31.cms-13-front</a></li><li><a href="../html/31.cms-14-deploy.html">31.cms-14-deploy</a></li><li><a href="../html/32.ant.html">32.ant</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li class="active"><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01. 全文搜索">1. 全文搜索</a></li><li><a href="#t12. 安装">2. 安装</a></li><li><a href="#t23. 访问">3. 访问</a></li><li><a href="#t34. 基本概念">4. 基本概念</a><ul><li><a href="#t4４.1 节点和集群">４.1 节点和集群</a></li><li><a href="#t54.2 索引">4.2 索引</a></li><li><a href="#t64.3 文档">4.3 文档</a></li><li><a href="#t74.4 类型(Type)">4.4 类型(Type)</a></li></ul></li><li><a href="#t85. 操作Index">5. 操作Index</a><ul><li><a href="#t95.1 创建索引">5.1 创建索引</a></li><li><a href="#t105.2 删除索引">5.2 删除索引</a></li></ul></li><li><a href="#t116. 数据操作">6. 数据操作</a><ul><li><a href="#t126.1 新增文档">6.1 新增文档</a></li><li><a href="#t136.2  查看文档">6.2  查看文档</a></li><li><a href="#t146.3 更新记录">6.3 更新记录</a></li><li><a href="#t156.4 删除文档">6.4 删除文档</a></li></ul></li><li><a href="#t167. 数据查询">7. 数据查询</a><ul><li><a href="#t177.1 查询全部">7.1 查询全部</a></li><li><a href="#t187.2 全文搜索">7.2 全文搜索</a></li><li><a href="#t197.3 OR">7.3 OR</a></li><li><a href="#t207.4 AND">7.4 AND</a></li></ul></li><li><a href="#t218. node中如何用">8. node中如何用</a></li><li><a href="#t229. 参考">9. 参考</a></li></ul>
    </div>
    
    <div class="content markdown-body">
        <h2 id="t01. &#x5168;&#x6587;&#x641C;&#x7D22;">1. &#x5168;&#x6587;&#x641C;&#x7D22; <a href="#t01. &#x5168;&#x6587;&#x641C;&#x7D22;"> # </a></h2>
<ul>
<li>&#x5F00;&#x6E90;&#x7684; Elasticsearch &#xFF08;&#x4EE5;&#x4E0B;&#x7B80;&#x79F0; Elastic&#xFF09;&#x662F;&#x76EE;&#x524D;&#x5168;&#x6587;&#x641C;&#x7D22;&#x5F15;&#x64CE;&#x7684;&#x9996;&#x9009;&#x3002;</li>
<li>&#x5B83;&#x53EF;&#x4EE5;&#x5FEB;&#x901F;&#x5730;&#x50A8;&#x5B58;&#x3001;&#x641C;&#x7D22;&#x548C;&#x5206;&#x6790;&#x6D77;&#x91CF;&#x6570;&#x636E;</li>
</ul>
<h2 id="t12. &#x5B89;&#x88C5;">2. &#x5B89;&#x88C5; <a href="#t12. &#x5B89;&#x88C5;"> # </a></h2>
<ol>
<li>&#x5B89;&#x88C5; <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">jdk</a></li>
<li>&#x5B89;&#x88C5; <a href="https://www.elastic.co/downloads/elasticsearch">elasticsearch</a></li>
</ol>
<h2 id="t23. &#x8BBF;&#x95EE;">3. &#x8BBF;&#x95EE; <a href="#t23. &#x8BBF;&#x95EE;"> # </a></h2>
<p><a href="http://localhost:9200/">http://localhost:9200/</a></p>
<pre><code class="lang-js">{
  <span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;PC-201704292335&quot;</span>, <span class="hljs-comment">//</span>
  <span class="hljs-string">&quot;cluster_name&quot;</span> : <span class="hljs-string">&quot;elasticsearch&quot;</span>&#xFF0C;<span class="hljs-comment">//&#x96C6;&#x7FA4;&#x540D;&#x79F0;</span>
  <span class="hljs-string">&quot;cluster_uuid&quot;</span> : <span class="hljs-string">&quot;pb4rTAeoSxyLgJGtyz4fAg&quot;</span>,<span class="hljs-comment">//&#x96C6;&#x7FA4;ID</span>
  <span class="hljs-string">&quot;version&quot;</span> : {
    <span class="hljs-string">&quot;number&quot;</span> : <span class="hljs-string">&quot;5.6.10&quot;</span>,
    <span class="hljs-string">&quot;build_hash&quot;</span> : <span class="hljs-string">&quot;b727a60&quot;</span>,
    <span class="hljs-string">&quot;build_date&quot;</span> : <span class="hljs-string">&quot;2018-06-06T15:48:34.860Z&quot;</span>,
    <span class="hljs-string">&quot;build_snapshot&quot;</span> : <span class="hljs-literal">false</span>,
    <span class="hljs-string">&quot;lucene_version&quot;</span> : <span class="hljs-string">&quot;6.6.1&quot;</span>
  },
  <span class="hljs-string">&quot;tagline&quot;</span> : <span class="hljs-string">&quot;You Know, for Search&quot;</span>
}
</code></pre>
<ul>
<li>C:\ProgramData\Elastic\Elasticsearch\config\elasticsearch.yml &#x914D;&#x7F6E;&#x6587;&#x4EF6;</li>
</ul>
<h2 id="t34. &#x57FA;&#x672C;&#x6982;&#x5FF5;">4. &#x57FA;&#x672C;&#x6982;&#x5FF5; <a href="#t34. &#x57FA;&#x672C;&#x6982;&#x5FF5;"> # </a></h2>
<h3 id="t4&#xFF14;.1 &#x8282;&#x70B9;&#x548C;&#x96C6;&#x7FA4;">&#xFF14;.1 &#x8282;&#x70B9;&#x548C;&#x96C6;&#x7FA4; <a href="#t4&#xFF14;.1 &#x8282;&#x70B9;&#x548C;&#x96C6;&#x7FA4;"> # </a></h3>
<ul>
<li>Elastic &#x672C;&#x8D28;&#x4E0A;&#x662F;&#x4E00;&#x4E2A;&#x5206;&#x5E03;&#x5F0F;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x5141;&#x8BB8;&#x591A;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x534F;&#x540C;&#x5DE5;&#x4F5C;&#xFF0C;&#x6BCF;&#x53F0;&#x670D;&#x52A1;&#x5668;&#x53EF;&#x4EE5;&#x8FD0;&#x884C;&#x591A;&#x4E2A; Elastic &#x5B9E;&#x4F8B;</li>
<li>&#x5355;&#x4E2A; Elastic &#x5B9E;&#x4F8B;&#x79F0;&#x4E3A;&#x4E00;&#x4E2A;&#x8282;&#x70B9;node&#x3002;&#x4E00;&#x7EC4;&#x8282;&#x70B9;&#x6784;&#x6210;&#x4E00;&#x4E2A;&#x96C6;&#x7FA4;cluster</li>
</ul>
<h3 id="t54.2 &#x7D22;&#x5F15;">4.2 &#x7D22;&#x5F15; <a href="#t54.2 &#x7D22;&#x5F15;"> # </a></h3>
<ul>
<li>Elastic &#x4F1A;&#x7D22;&#x5F15;&#x6240;&#x6709;&#x5B57;&#x6BB5;&#xFF0C;&#x7ECF;&#x8FC7;&#x5904;&#x7406;&#x540E;&#x5199;&#x5165;&#x4E00;&#x4E2A;&#x53CD;&#x5411;&#x7D22;&#x5F15;&#xFF08;Inverted Index&#xFF09;&#x3002;&#x67E5;&#x627E;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x76F4;&#x63A5;&#x67E5;&#x627E;&#x8BE5;&#x7D22;&#x5F15;</li>
<li>Elastic &#x6570;&#x636E;&#x7BA1;&#x7406;&#x7684;&#x9876;&#x5C42;&#x5355;&#x4F4D;&#x5C31;&#x53EB;&#x505A; Index&#xFF08;&#x7D22;&#x5F15;&#xFF09;&#xFF0C;Index &#xFF08;&#x5373;&#x6570;&#x636E;&#x5E93;&#xFF09;&#x7684;&#x540D;&#x5B57;&#x5FC5;&#x987B;&#x662F;&#x5C0F;&#x5199;</li>
</ul>
<h3 id="t64.3 &#x6587;&#x6863;">4.3 &#x6587;&#x6863; <a href="#t64.3 &#x6587;&#x6863;"> # </a></h3>
<ul>
<li>Index &#x91CC;&#x9762;&#x5355;&#x6761;&#x7684;&#x8BB0;&#x5F55;&#x79F0;&#x4E3A; Document&#xFF08;&#x6587;&#x6863;&#xFF09;</li>
<li>&#x8BB8;&#x591A;&#x6761; Document &#x6784;&#x6210;&#x4E86;&#x4E00;&#x4E2A; Index</li>
<li>Document &#x4F7F;&#x7528; JSON &#x683C;&#x5F0F;&#x8868;&#x793A;</li>
</ul>
<h3 id="t74.4 &#x7C7B;&#x578B;(Type)">4.4 &#x7C7B;&#x578B;(Type) <a href="#t74.4 &#x7C7B;&#x578B;(Type)"> # </a></h3>
<ul>
<li>&#x6587;&#x6863;&#x53EF;&#x4EE5;&#x5206;&#x7EC4;&#xFF0C;&#x6BD4;&#x5982;&#x5B66;&#x751F;&#x8FD9;&#x4E2A;Index&#x91CC;&#x9762;&#xFF0C;&#x53EF;&#x4EE5;&#x6309;&#x59D3;&#x522B;&#x5206;&#x7EC4;(&#x7537;&#x751F;&#x4E00;&#x7EC4;&#xFF0C;&#x5973;&#x751F;&#x4E00;&#x7EC4;)&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x6309;&#x7701;&#x4EFD;&#x5206;&#x7EC4;(&#x5317;&#x4EAC;&#x548C;&#x5E7F;&#x4E1C;)</li>
<li>&#x8FD9;&#x79CD;&#x5206;&#x7EC4;&#x5C31;&#x53EB;&#x505A;&#x7C7B;&#x578B;&#xFF0C;&#x5B83;&#x662F;&#x865A;&#x62DF;&#x7684;&#x903B;&#x8F91;&#x5206;&#x7EC4;&#xFF0C;&#x7528;&#x6765;&#x8FC7;&#x6EE4;&#x6587;&#x6863;</li>
<li>&#x4E0D;&#x540C;&#x7684;&#x7C7B;&#x578B;&#x5E94;&#x8BE5;&#x6709;&#x76F8;&#x4F3C;&#x7684;&#x7ED3;&#x6784;</li>
<li>&#x6BCF;&#x4E2A; Index &#x5305;&#x542B;&#x4E00;&#x4E2A; Type&#xFF0C;7.x &#x7248;&#x5C06;&#x4F1A;&#x5F7B;&#x5E95;&#x79FB;&#x9664; Type</li>
</ul>
<h2 id="t85. &#x64CD;&#x4F5C;Index">5. &#x64CD;&#x4F5C;Index <a href="#t85. &#x64CD;&#x4F5C;Index"> # </a></h2>
<h3 id="t95.1 &#x521B;&#x5EFA;&#x7D22;&#x5F15;">5.1 &#x521B;&#x5EFA;&#x7D22;&#x5F15; <a href="#t95.1 &#x521B;&#x5EFA;&#x7D22;&#x5F15;"> # </a></h3>
<pre><code class="lang-js">curl -X PUT <span class="hljs-string">&apos;http://localhost:9200/student&apos;</span>
</code></pre>
<ul>
<li>&#x4E0D;&#x80FD;&#x6709;&#x8BF7;&#x6C42;&#x4F53;</li>
</ul>
<h3 id="t105.2 &#x5220;&#x9664;&#x7D22;&#x5F15;">5.2 &#x5220;&#x9664;&#x7D22;&#x5F15; <a href="#t105.2 &#x5220;&#x9664;&#x7D22;&#x5F15;"> # </a></h3>
<pre><code class="lang-js">curl -X DELETE <span class="hljs-string">&apos;http://localhost:9200/student&apos;</span>
</code></pre>
<h2 id="t116. &#x6570;&#x636E;&#x64CD;&#x4F5C;">6. &#x6570;&#x636E;&#x64CD;&#x4F5C; <a href="#t116. &#x6570;&#x636E;&#x64CD;&#x4F5C;"> # </a></h2>
<h3 id="t126.1 &#x65B0;&#x589E;&#x6587;&#x6863;">6.1 &#x65B0;&#x589E;&#x6587;&#x6863; <a href="#t126.1 &#x65B0;&#x589E;&#x6587;&#x6863;"> # </a></h3>
<pre><code class="lang-js">curl -X PUT <span class="hljs-string">&apos;http://localhost:9200/student/city/1&apos;</span> -d<span class="hljs-string">`
{
    &quot;name&quot;:&quot;&#x5F20;&#x4E09;&quot;,
    &quot;age&quot;:5,
    &quot;city&quot;:&quot;&#x5317;&#x4EAC;&quot;
}
`</span>
</code></pre>
<pre><code class="lang-js">curl -X POST <span class="hljs-string">&apos;http://localhost:9200/student/city&apos;</span> -d<span class="hljs-string">`
{
    &quot;name&quot;:&quot;&#x8D75;&#x516D;&quot;,
    &quot;age&quot;:7,
    &quot;city&quot;:&quot;&#x6C5F;&#x82CF;&quot;
}
`</span>
</code></pre>
<h3 id="t136.2  &#x67E5;&#x770B;&#x6587;&#x6863;">6.2  &#x67E5;&#x770B;&#x6587;&#x6863; <a href="#t136.2  &#x67E5;&#x770B;&#x6587;&#x6863;"> # </a></h3>
<pre><code class="lang-js">curl <span class="hljs-string">&apos;http://localhost:9200/student/city/1&apos;</span>
</code></pre>
<h3 id="t146.3 &#x66F4;&#x65B0;&#x8BB0;&#x5F55;">6.3 &#x66F4;&#x65B0;&#x8BB0;&#x5F55; <a href="#t146.3 &#x66F4;&#x65B0;&#x8BB0;&#x5F55;"> # </a></h3>
<pre><code class="lang-js">curl -X PUT <span class="hljs-string">&apos;http://localhost:9200/student/city/1&apos;</span> -d<span class="hljs-string">`
{
    &quot;name&quot;:&quot;&#x5F20;&#x4E09;2&quot;,
    &quot;age&quot;:55,
    &quot;city&quot;:&quot;&#x5317;&#x4EAC;2&quot;
}
</span></code></pre>
<h3 id="t156.4 &#x5220;&#x9664;&#x6587;&#x6863;">6.4 &#x5220;&#x9664;&#x6587;&#x6863; <a href="#t156.4 &#x5220;&#x9664;&#x6587;&#x6863;"> # </a></h3>
<pre><code class="lang-js">curl -X DELETE <span class="hljs-string">&apos;http://localhost:9200/student/city/1&apos;</span>
</code></pre>
<h2 id="t167. &#x6570;&#x636E;&#x67E5;&#x8BE2;">7. &#x6570;&#x636E;&#x67E5;&#x8BE2; <a href="#t167. &#x6570;&#x636E;&#x67E5;&#x8BE2;"> # </a></h2>
<h3 id="t177.1 &#x67E5;&#x8BE2;&#x5168;&#x90E8;">7.1 &#x67E5;&#x8BE2;&#x5168;&#x90E8; <a href="#t177.1 &#x67E5;&#x8BE2;&#x5168;&#x90E8;"> # </a></h3>
<pre><code class="lang-js">curl <span class="hljs-string">&apos;http://localhost:9200/student/city/_search&apos;</span>
</code></pre>
<h3 id="t187.2 &#x5168;&#x6587;&#x641C;&#x7D22;">7.2 &#x5168;&#x6587;&#x641C;&#x7D22; <a href="#t187.2 &#x5168;&#x6587;&#x641C;&#x7D22;"> # </a></h3>
<pre><code class="lang-js">curl <span class="hljs-string">&apos;http://localhost:9200/student/city/_search&apos;</span> -d <span class="hljs-string">`
{
  &quot;query&quot; : { &quot;match&quot; : { &quot;name&quot; : &quot;&#x674E;&quot; }},
  &quot;size&quot;:1,
  &quot;from&quot;:1
}
`</span>
</code></pre>
<h3 id="t197.3 OR">7.3 OR <a href="#t197.3 OR"> # </a></h3>
<pre><code class="lang-js">curl <span class="hljs-string">&apos;http://localhost:9200/student/city/_search&apos;</span> -d <span class="hljs-string">`
{
  &quot;query&quot; : { &quot;match&quot; : { &quot;name&quot; : &quot;&#x8D75; &#x674E;&quot; }}
}
`</span>
</code></pre>
<h3 id="t207.4 AND">7.4 AND <a href="#t207.4 AND"> # </a></h3>
<pre><code class="lang-js">curl <span class="hljs-string">&apos;http://localhost:9200/student/city/_search&apos;</span> -d <span class="hljs-string">`
{
  &quot;query&quot;: {
    &quot;bool&quot;: {
      &quot;must&quot;: [
        { &quot;match&quot;: { &quot;name&quot;: &quot;&#x8D75;&quot; } },
        { &quot;match&quot;: { &quot;name&quot;: &quot;&#x516D;&quot; } }
      ]
    }
  }
}
`</span>
</code></pre>
<h2 id="t218. node&#x4E2D;&#x5982;&#x4F55;&#x7528;">8. node&#x4E2D;&#x5982;&#x4F55;&#x7528; <a href="#t218. node&#x4E2D;&#x5982;&#x4F55;&#x7528;"> # </a></h2>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> elasticsearch = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;elasticsearch&apos;</span>);
<span class="hljs-keyword">var</span> client = <span class="hljs-keyword">new</span> elasticsearch.Client({
    <span class="hljs-attr">host</span>: <span class="hljs-string">&apos;localhost:9200&apos;</span>,
    <span class="hljs-attr">log</span>: <span class="hljs-string">&apos;trace&apos;</span>
});
<span class="hljs-comment">/**
client.search({
    index: &apos;student&apos;,
    type: &apos;city&apos;,
    body: {
        query: {
            match: {
                name: &apos;&#x8D75;&apos;
            }
        }
    }
}).then(ret =&gt; {
    console.log(ret.hits.hits);
});
 */</span>
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> name = <span class="hljs-built_in">Date</span>.now();
    <span class="hljs-keyword">let</span> id = <span class="hljs-built_in">Date</span>.now();
    <span class="hljs-keyword">const</span> created = <span class="hljs-keyword">await</span> client.create({
        <span class="hljs-attr">index</span>: <span class="hljs-string">&apos;student&apos;</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">&apos;city&apos;</span>,
        id,
        <span class="hljs-attr">body</span>: {
            name,
            <span class="hljs-attr">age</span>: <span class="hljs-number">10</span>
        }
    });
    <span class="hljs-built_in">console</span>.log(created);
    <span class="hljs-keyword">const</span> updated = <span class="hljs-keyword">await</span> client.update({
        <span class="hljs-attr">index</span>: <span class="hljs-string">&apos;student&apos;</span>,
        <span class="hljs-attr">type</span>: <span class="hljs-string">&apos;city&apos;</span>,
        id,
        <span class="hljs-attr">body</span>: {
            <span class="hljs-attr">doc</span>: {
                <span class="hljs-attr">name</span>: name,
                <span class="hljs-attr">age</span>: <span class="hljs-number">101</span>
            }
        }
    });
    <span class="hljs-built_in">console</span>.log(created);
    <span class="hljs-comment">//shift+alt+a</span>
    <span class="hljs-comment">/*  const deleted = await client.delete({
         index: &apos;student&apos;,
         type: &apos;city&apos;,
         id
     }); */</span>
    <span class="hljs-built_in">console</span>.log(deleted);
})().then(<span class="hljs-function"><span class="hljs-params">ret</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(ret), err =&gt; <span class="hljs-built_in">console</span>.log(err));

<span class="hljs-comment">//</span>
</code></pre>
<h2 id="t229. &#x53C2;&#x8003;">9. &#x53C2;&#x8003; <a href="#t229. &#x53C2;&#x8003;"> # </a></h2>
<ul>
<li><a href="https://www.elastic.co/cn/">elastic</a></li>
<li><a href="https://www.elastic.co/downloads/elasticsearch">installation</a></li>
<li><a href="https://github.com/elastic/elasticsearch-js">elasticsearch</a></li>
<li><a href="https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-delete">api</a></li>
</ul>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
